class User {
  constructor(id, username, phone, password_hash, created_at, updated_at) {
    this.id = id;
    this.username = username;
    this.phone = phone;
    this.password_hash = password_hash;
    this.created_at = created_at;
    this.updated_at = updated_at;
  }

  // Create a User instance from a database row
  static fromRow(row) {
    return new User(
      row.id,
      row.username,
      row.phone,
      row.password_hash,
      row.created_at,
      row.updated_at
    );
  }

  // Convert User instance to JSON (excluding sensitive data)
  toJSON() {
    return {
      id: this.id,
      username: this.username,
      phone: this.phone,
      created_at: this.created_at,
      updated_at: this.updated_at
    };
  }
}

module.exports = User;